package cn.edu.service.impl;

import cn.edu.dao.dep_TeacherDao;
import cn.edu.domain.*;
import cn.edu.service.dep_TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Davey chan
 */
@Service
public  class dep_TeacherServiceImpl implements dep_TeacherService {
    @Autowired
   private dep_TeacherDao teacherDao;
    @Override
    public PageBean<All> selectByPageAndcondition(int currentPage, int pageSize, All t) {
        int begin=(currentPage-1)*pageSize;
//        计算查询的条目数
        int size =pageSize;
//        处理查询条件，模糊查询
        String teacherName = t.getTeacherName();
        if(teacherName !=null && teacherName.length()>0){
            t.setTeacherName("%"+teacherName+"%");
        }
        String title = t.getTitle();
        if(title !=null && title.length()>0){
            t.setTitle("%"+title+"%");
        }
        t.setExamstatus("3");

        List<All> rows = teacherDao.selectBypageAndCondtion(begin, size,t);
//        查询总记录数
        int totalCount = teacherDao.selectTotalCountByCondition(t);
//封装pageBean
        PageBean<All> pageBean=new PageBean<>();
        pageBean.setRows(rows);
        pageBean.setTotalCount(totalCount);
        return pageBean;
    }

    @Override
    public void delteacher(Integer id) {

        teacherDao.delteacher(id);

    }

    @Override
    public void Updateteach_work(teach_work t) {
        teacherDao.UpdateTeach_work(t);
    }

    @Override
    public void UpdateAnnual_examination(annual_examination t) {

        teacherDao.UpdateAnnual_exam(t);

    }

    @Override
    public void UpdatePatent(patent t) {
        teacherDao.UpdatePatent(t);
    }

    @Override
    public void UpdateOpus(opus t) {
        teacherDao.UpdateOpus(t);
    }

    @Override
    public void UpdateThesis(thesis t) {

        teacherDao.UpdateThesis(t);

    }

    @Override
    public void UpdateTrain(train t) {
        teacherDao.UpdateTrain(t);
    }

    @Override
    public void UpdateWork(work t) {
        teacherDao.UpdateWork(t);
    }

    @Override
    public void UpdateHonor(honor_title t) {
        teacherDao.UpdateHonor(t);
    }
    @Override
    public void UpdateAward(award t) {
        teacherDao.UpdateAward(t);
    }
    @Override
    public void UpdateResearch_project(research_project t) {
        teacherDao.UpdateResearch_project(t);
    }


}
